package com.matrix.java.chap_05;

import java.util.Scanner;

public class Ex5_02 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int count = 0;
        int countRight = 0;
        long startTime = System.currentTimeMillis();
        while (count < 10) {
            int num1 = (int) (Math.random() * 14) + 1;
            int num2 = (int) (Math.random() * 14) + 1;
            int sum = num1 + num2;
            System.out.print(num1 + "+" + num2 + "=?");
            int guessNum = input.nextInt();
            if (guessNum == sum) {
                System.out.println("correct");
                countRight++;
            }
            count++;
        }
        long endTime = System.currentTimeMillis();
        long spendTime = endTime - startTime;
        System.out.println("正确: " + countRight + "时间: " + spendTime + "ms");
        input.close();
    }
}
